package com.smalldoor.thread.demo03;

//守护线程
public class ThreadDaemon {

    public static void main(String[] args) {
        God god = new God();
        You you = new You();

        Thread t1 = new Thread(god);
        t1.setDaemon(true);

        t1.start();

        new Thread(you).start();
    }
}

class You implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i <= 100; i++) {
            if (i <100) {
                System.out.println("YOU");
            }else {
                System.out.println("YOU LEAVE");
            }
        }
    }
}

class God implements Runnable{

    @Override
    public void run() {
        while (true) {
            System.out.println("GOD ALWAYS HERE");
        }
    }
}
